feat(state): Implement LangGraph checkpoint management with OTS integ…#80
feat(state): Implement LangGraph checkpoint management with OTS integ…#80
Conversation
…ration - Added checkpoint, checkpoint_writes, and checkpoint_blobs tables to support LangGraph functionality. - Introduced asynchronous methods for initializing and managing checkpoint tables in OTSBackend and SessionStore. - Enhanced SessionStore with methods for checkpoint CRUD operations. - Updated README and conversation_design.md to document new checkpoint features and usage examples. - Refactored utils to build OTS clients independently of code generation templates. This update enables persistent storage of LangGraph checkpoints, enhancing the overall functionality of the conversation service.
|
@copilot codereview |
Code Review — feat(state): LangGraph checkpoint management with OTS integrationOverviewThe PR introduces LangGraph checkpoint persistence via OTS, with three new tables ( Issues Found🔴 Bug: Section comment / method ordering is swapped in two places
# -----------------------------------------------------------------------
# Checkpoint CRUD(LangGraph)(异步) ← says "async"
# -----------------------------------------------------------------------
def delete_state_row(...) ← this is a SYNC method, belongs above
...
# -----------------------------------------------------------------------
# Checkpoint CRUD(LangGraph)(同步) ← says "sync"
# -----------------------------------------------------------------------
async def put_checkpoint_async(...) ← this is an ASYNC methodThe sync
# Checkpoint 管理(LangGraph)(异步) ← says "async"
def init_langgraph_tables(...) ← SYNC method
# Checkpoint 管理(LangGraph)(同步) ← says "sync"
async def put_checkpoint_async(...) ← ASYNC methodAlso at line 380: 🟠 Design concern:
|
- Fix sync/async section comment headers in ots_backend.py and session_store.py - Add langgraph optional dependency in pyproject.toml - Improve build_ots_clients return type annotation with TYPE_CHECKING import - Handle missing state table gracefully in init_search_index Made-with: Cursor
ots_backend.py 中 delete_state_row(同步)误放在 "Checkpoint CRUD(异步)" 标题下,后面的 put_checkpoint_async(异步)误放在 "Checkpoint CRUD(同步)" 标题下。session_store.py 中同样存在类似问题。 修复: ots_backend.py:delete_state_row 上方改为 "State CRUD(同步)",异步/同步 checkpoint 方法各加正确 section header Reviewer 认为 LangGraph 使用 UUID v4(随机),字典序不等于时间序。实际验证发现 LangGraph 使用 UUID v6(时间有序),其高位为时间戳,字典序严格等于生成顺序:
新增: langgraph = [
_sync_session 调用 get_session() 判断 create vs update,确实多一次点读。但: get_session 是 OTS 点读(GetRow),延迟通常 < 5ms
验证 LangGraph 基类签名:
LangGraph checkpoint 涉及 OTS 真实读写,需要 mock 或集成测试环境。已有端到端验证(example 脚本),将在下一个 PR 补充以下单元测试: OTSCheckpointSaver.put/get/list 的 mock 测试 添加 TYPE_CHECKING 导入块,返回类型改为 tuple[OTSClient, AsyncOTSClient],保留静态类型信息。 |
…ration
This update enables persistent storage of LangGraph checkpoints, enhancing the overall functionality of the conversation service.
Fix bugs
Bug detail
Pull request tasks
Update docs
Reason for update
Pull request tasks
Add contributor
Contributed content
Content detail
Others
Reason for update